<script>
export default {
  name: 'ZFields',
  inject: [
    'curFormCon'
  ],
  props: {
    // con: {
    //   type: Object,
    //   default() {
    //     return {}
    //   }
    // },
    binds: {
      type: Object,
      default() {
        return {}
      }
    },
    tag: {
      type: String,
      default: 'div'
    },
  },
  computed: {
    wrap_start_tag_props() {
      let s = ZY.lodash.get(this.binds, 'config.ui.wrap_start_tag_props')
      if (!s) {
        return {}
      }
      return s
    }
  },
  render(h, context) {
    // console.log(this.binds)
    let tag = ZY.lodash.get(this.wrap_start_tag_props, 'tag', this.tag)
    let tagAttrs = ZY.lodash.get(this.wrap_start_tag_props, 'tagProps', {})
    // console.log(tagAttrs)
    let showed = true
    let slots = this.$slots.default
    let str = ZY.lodash.get(this.binds, 'config.ui.condition.str')
    if (!str) {
      str = ZY.lodash.get(this.binds, 'config.ui.condition')
    }
    // console.log(str)
    if (str) {
      showed = this.curFormCon.evalCon(str, this.binds)
    }
    let style = {
    }
    if (!showed) {
      style.display = 'none'
    }

    // console.log(tagAttrs)
    return (<tag style={style} {...{props: tagAttrs}}>{slots}</tag>)
  }
}
</script>
